package com.grts.mall.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.grts.mall.common.CommonResult;
import com.grts.mall.pojo.Product;
import com.grts.mall.pojo.vo.ProductSearchConditionVo;
import com.grts.mall.service.ProductService;

@Controller
public class HomeController {
	
	@Autowired
	private ProductService productService;
	
	@RequestMapping("/home")
	@ResponseBody
	public String home() {
		return "this is home controller";
	}
	
	@RequestMapping("/product/news")
	@ResponseBody
	public CommonResult newProducts(@RequestParam(name="num",defaultValue = "7") Integer num) {
		List<Product> data = this.productService.findNewProduct(num);
		return CommonResult.success(data);
	}
	@RequestMapping("/product/hots")
	@ResponseBody
	public CommonResult hotProduct(@RequestParam(name="num",defaultValue = "2") Integer num) {
		List<Product> data = this.productService.findHotProduct(num);
		return CommonResult.success(data);
	}
	
	
}
	
	
